FROM quay.io/toolbx-images/archlinux-toolbox
ARG S6_OVERLAY_VERSION=3.1.6.0

RUN echo "Server = https://mirror.sjtu.edu.cn/archlinux/\$repo/os/\$arch" > /etc/pacman.d/mirrorlist
RUN pacman -Syyu --noconfirm && pacman -S --noconfirm git cmake gcc gstreamer gstreamer-vaapi make pkgconf sdbus-cpp gtkmm-4.0 yaml-cpp fmt spdlog asio boost
RUN git clone https://github.com/msgpack/msgpack-c.git -b cpp_master && mkdir /msgpack-c/build && cd /msgpack-c/build && cmake .. && make -j8 && make install
RUN git clone https://github.com/CrowCpp/Crow.git && mkdir /Crow/build && cd /Crow/build && cmake .. && make -j8 && make install
RUN git clone https://github.com/SpartanJ/SOIL2.git && mkdir /SOIL2/build && cd /SOIL2/build && cmake .. && make -j8 && make install
RUN pacman -S --noconfirm pugixml glfw-wayland glew postgresql nlohmann-json glm python
RUN git clone https://github.com/jtv/libpqxx.git && mkdir /libpqxx/build && cd /libpqxx/build && cmake ..  -DCMAKE_CXX_STANDARD=20 && make -j8 && make install
RUN git clone https://15968426049:klYdW%3\(\@gitee.com/tootDebug/HebeiSportSystem.git
RUN cd /HebeiSportSystem && mkdir build && cd build && cmake .. && make -j8 

RUN pacman -Syyu --noconfirm && pacman -S --noconfirm  systemd dbus

#执行清理
RUN pacman -Scc --noconfirm && rm -rf /msgpack-c && rm -rf /Crow && rm -rf /SOIL2 && rm -rf /libpqxx && rm -rf /pugixml

#安装s6
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-noarch.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-noarch.tar.xz
ADD https://github.com/just-containers/s6-overlay/releases/download/v${S6_OVERLAY_VERSION}/s6-overlay-x86_64.tar.xz /tmp
RUN tar -C / -Jxpf /tmp/s6-overlay-x86_64.tar.xz

#拷贝启动配置
COPY s6Boot/ /etc/s6-overlay/s6-rc.d/user/contents.d/
COPY s6/ /etc/s6-overlay/s6-rc.d/
RUN mv /etc/s6-overlay/s6-rc.d/CameraCollege/test1080P.jpg /HebeiSportSystem/build/ecam-college/
RUN mv /etc/s6-overlay/s6-rc.d/EnvInit/InitEnv.sh / && chmod +x /InitEnv.sh
RUN mkdir /home/shenzhe && useradd -m shenzhe -s /bin/bash -d /home/shenzhe -u 1000 && chown 1000:1000 -R /home/shenzhe

#镜像信息
EXPOSE 10090
VOLUME /config
VOLUME /HBTY_Data
ENTRYPOINT ["/init"]
